package com.dldata.devtools30.controller;

import com.alibaba.fastjson.JSON;
import com.dldata.devtools30.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;

/**
 * Created by zhw on 2020-09-22.
 */
@Controller
@RequestMapping("demo30")
@Slf4j
public class TestDemo30Controller {
    
    @RequestMapping("getDemoJSON")
    @ResponseBody
    public Object getDemoJSON(HttpServletRequest request, HttpServletResponse response , Map param) throws IOException {
        log.info(JSON.toJSONString(param));
        HashMap<Object, Object> data = new HashMap<>();
        data.put("TMP_TESTMAINTABLE@TESTINPUTTEXT","TESTINPUTTEXT_"+new Random().nextGaussian());
        return Result.ok(data);
    }
    
    @RequestMapping("postDemoJSON")
    @ResponseBody
    public Object postDemoJSON(HttpServletRequest request, HttpServletResponse response , Map param) throws IOException {
        log.info(JSON.toJSONString(param));
        return Result.ok();
    }
}
